﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;

namespace WindowsGame1.Model
{
    class BallSimulation
    {
        public Ball m_ball;
        //private Rectangle m_arenaRect;

        public BallSimulation() 
        {
            m_ball = new Ball();
            //m_arenaRect = new Rectangle(0,0,1,1);
        }

        public void Update() 
        {
            m_ball.m_position += m_ball.m_speed;
            CollisionHandling();
        }

        public void CollisionHandling() 
        {
            if (m_ball.m_position.X + (float)m_ball.m_diameter > 1f)
            {
                m_ball.m_speed.X = m_ball.m_speed.X * -1;
                //m_ball.m_position.X = 1.0f - (float)m_ball.m_diameter;
            }
            else if (m_ball.m_position.X < 0f)
            {
                m_ball.m_speed.X = m_ball.m_speed.X * -1;
                //m_ball.m_position.X = 0.5f;
            }
            if (m_ball.m_position.Y + (float)m_ball.m_diameter > 1f)
            {
                m_ball.m_speed.Y = m_ball.m_speed.Y * -1;
                //m_ball.m_position.Y = 1.0f - (float)m_ball.m_diameter;
            }
            else if (m_ball.m_position.Y < 0f)
            {
                m_ball.m_speed.Y = m_ball.m_speed.Y * -1;
                //m_ball.m_position.Y = 0.5f;
            }
        }
    }
}
